package org.bw.bookstore.book.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bw.bookstore.book.service.impl.StaffMemberServiceImpl;
import org.bw.bookstore.common.entity.TbStaffMember;
import org.bw.bookstore.common.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @program:wisdom_bookstore
 * @description: 管理人员控制类
 * @author:liuwu
 * @create:2020-10-22 13:59
 **/
@RestController
@Slf4j
@CrossOrigin
@RequestMapping("staffMember")
@Api(tags = "接口-管理人员")
public class StaffMemberController {

    @Autowired
    private StaffMemberServiceImpl staffMemberService;

    @ApiOperation(value = "添加管理人员", notes = "添加管理人员")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "realName", value = "职员真实姓名", dataType = "string", required = true),
            @ApiImplicitParam(name = "userName", value = "职员姓名", dataType = "string", required = true),
            @ApiImplicitParam(name = "staffMemberPhone", value = "职员手机号", dataType = "string", required = true),
            @ApiImplicitParam(name = "specificPosition", value = "具体职位", dataType = "int", required = true),
            @ApiImplicitParam(name = "userPass", value = "密码", dataType = "string", required = true),
            @ApiImplicitParam(name = "shopCode", value = "所属店铺", dataType = "string", required = true),
    })
    @PostMapping("/addStaffMember")
    public ResponseResult addStaffMember(@ApiIgnore TbStaffMember staffMember){
        return staffMemberService.addStaffMember(staffMember);
    }

    @ApiOperation(value = "删除管理人员", notes = "删除管理人员")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "管理人员id", dataType = "Integer", required = true)
    })
    @PostMapping("/delStaffMember")
    public ResponseResult delStaffMember(Integer id){
        return staffMemberService.delStaffMember(id);
    }

    @ApiOperation(value = "修改管理人员", notes = "修改管理人员")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "职员id", dataType = "int", required = true),
            @ApiImplicitParam(name = "realName", value = "职员真实姓名", dataType = "string", required = false),
            @ApiImplicitParam(name = "userName", value = "职员姓名", dataType = "string", required = false),
            @ApiImplicitParam(name = "staffMemberPhone", value = "职员手机号", dataType = "string", required = false),
            @ApiImplicitParam(name = "specificPosition", value = "具体职位", dataType = "int", required = false),
            @ApiImplicitParam(name = "userPass", value = "密码", dataType = "string", required = false),
            @ApiImplicitParam(name = "shopCode", value = "所属店铺", dataType = "string", required = false),
            @ApiImplicitParam(name = "updateTime", value = "修改时间", dataType = "Date", required = false),
    })
    @PostMapping("/updateStaffMember")
    public ResponseResult updateStaffMember(@ApiIgnore TbStaffMember staffMember){
        return staffMemberService.updateStaffMember(staffMember);
    }

    @ApiOperation(value = "管理人员登录", notes = "管理人员登录")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "userName", value = "管理人员账号", dataType = "String", required = true),
            @ApiImplicitParam(name = "userPass", value = "管理人员密码", dataType = "String", required = true)
    })
    @PostMapping("/loginStaffMember")
    public ResponseResult loginStaffMember(String userName,String userPass){
        return staffMemberService.loginStaffMember(userName,userPass);
    }

    @ApiOperation(value = "查询全部管理人员", notes = "查询全部管理人员")
    @GetMapping("/getStaffMember")
    public ResponseResult getStaffMember(){
        return staffMemberService.getStaffMember();
    }


    @ApiOperation(value = "根据id查询管理人员", notes = "根据id查询管理人员")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "管理人员id", dataType = "Integer", required = true)
    })
    @GetMapping("/getStaffMemberById")
    public ResponseResult getStaffMemberById(Integer id){
        return staffMemberService.getStaffMemberById(id);
    }


    @ApiOperation(value = "根据条件查询管理人员", notes = "根据条件查询管理人员")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "realName", value = "职员真实姓名", dataType = "String", required = false),
            @ApiImplicitParam(name = "staffMemberPhone", value = "职员手机号", dataType = "String", required = false),
            @ApiImplicitParam(name = "specificPosition", value = "具体职位", dataType = "Integer", required = false),
            @ApiImplicitParam(name="currentPage", value = "当前页", dataType = "Integer", required=true,example = "0"),
            @ApiImplicitParam(name="pageSize", value = "每页多少条", dataType = "Integer", required=true,example = "0")
    })
    @PostMapping("/getStaffMemberBySomething")
    public ResponseResult getStaffMemberBySomething(@RequestBody TbStaffMember staffMember,
                                                    @RequestParam("currentPage") Integer currentPage,
                                                    @RequestParam("pageSize") Integer pageSize){
        return staffMemberService.getStaffMemberBySomething(staffMember,currentPage,pageSize);
    }


}
